package Code.Basic.Entity;

import org.jrabbit.base.math.geom.Geometry;
import org.jrabbit.standard.game.graphics.skins.animation.AnimatedSkin;
import org.jrabbit.standard.game.objects.specialized.AnimatedSprite;

import Code.Basic.World.GameWorld;

public class GenericEffect extends AnimatedSprite
{
	protected Geometry shape;
	
	protected GameWorld gameWorld;
	
	protected boolean[] targetsAllowed = new boolean[] {true, true, true};
	
	public GenericEffect(String filepath)
	{
		super(new AnimatedSkin(filepath));
		setup();
	}
	
	public GenericEffect(AnimatedSkin skin)
	{
		super(skin);
		setup();
	}
	
	protected void setup()
	{
		gameWorld = null;
		shape = new Geometry(getWidth(), getHeight());
	}
	
	public void setWorld(GameWorld w)
	{
		gameWorld = w;
	}
	
	public GameWorld getGameWorld()
	{
		return gameWorld;
	}
	
	public Geometry getGeometry()
	{
		return shape;
	}
	
	public boolean intersects(PhysicsSprite p)
	{
		if(shape.intersects(p.getGeometry()))
		{
			return true;
		}
		return false;
	}
	
	public void updateGeometry()
	{
		shape.updateShape(location, rotation, scalar);
	}
	
	public void affect(GenericCharacter gC)
	{
		
	}
	
	public void collideWithStructure(PhysicsSprite p)
	{
		getGameWorld().removeEffect(this);
	}
	
	public void update(int delta)
	{
		super.update(delta);
		updateGeometry();
	}
}
